local weijie = fk.CreateSkill{
  name = "hanqing__weijie",
}

Fk:loadTranslationTable{
  ["hanqing__weijie"] = "巍阶",
  [":hanqing__weijie"] = "若你处于〖霸武〗的连招状态，你可以视为使用一张【决斗】；若你已横置，你可以视为使用一张无次数限制的【杀】。"..
  "若均满足，此技能失效。",

  ["#hanqing__weijie-duel"] = "巍阶：你可以视为使用【决斗】",
  ["#hanqing__weijie-slash"] = "巍阶：你可以视为使用一张无次数限制的【杀】",
}

weijie:addEffect("viewas", {
  anim_type = "offensive",
  pattern = "slash,duel",
  prompt = function (self, player, selected_cards, selected)
    if player.chained then
      return "#hanqing__weijie-slash"
    elseif player:getMark("hanqing__bawu") == 1 then
      return "#hanqing__weijie-duel"
    end
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if #cards ~= 0 then return end
    local card = Fk:cloneCard("duel")
    if player.chained then
      card = Fk:cloneCard("slash")
    end
    card.skillName = weijie.name
    return card
  end,
  before_use = function (self, player, use)
    use.extraUse = true
  end,
  enabled_at_play = function (self, player)
    if player.chained then
      return player:getMark("hanqing__bawu") ~= 1 and
        #player:getViewAsCardNames(weijie.name, {"slash"}, nil, nil, { bypass_times = true }) > 0
    else
      return player:getMark("hanqing__bawu") == 1 and
        #player:getViewAsCardNames(weijie.name, {"duel"}) > 0
    end
  end,
  enabled_at_response = function (self, player, response)
    if response then return end
    if player.chained then
      return player:getMark("hanqing__bawu") ~= 1 and
        #player:getViewAsCardNames(weijie.name, {"slash"}, nil, nil, { bypass_times = true }) > 0
    else
      return player:getMark("hanqing__bawu") == 1 and
        #player:getViewAsCardNames(weijie.name, {"duel"}) > 0
    end
  end
})

weijie:addEffect("targetmod", {
  bypass_times = function (self, player, skill, scope, card, to)
    return card and table.contains(card.skillNames, weijie.name)
  end,
})

weijie:addAI(nil, "vs_skill")

return weijie
